<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="layui/css/layui.css">
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script src="layui/layui.js" charset="utf-8"></script>
<title>电子银行——》内部转账</title>
<script type="text/javascript">
function getDate(){
	function p(s) {
	    return s < 10 ? '0' + s: s;
	}

	var myDate = new Date();
	//获取当前年
	var year=myDate.getFullYear();
	//获取当前月
	var month=myDate.getMonth()+1;
	//获取当前日
	var date=myDate.getDate(); 
	var h=myDate.getHours();       //获取当前小时数(0-23)
	var m=myDate.getMinutes();     //获取当前分钟数(0-59)
	var s=myDate.getSeconds();  
	
	//var now=year+'-'+p(month)+"-"+p(date)+" "+p(h)+':'+p(m)+":"+p(s);//时间格式：yyyy-MM-DD HH:mm:ss 
	var now=year+'-'+p(month)+"-"+p(date);//时间格式：yyyy-MM-DD 
	
	return now;
}
</script>

<script>
layui.use('layer', function(){ //独立版的layer无需执行这一句
  var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
  
  //触发事件
  var active = {
    notice: function(){
    	var rid=$("#rid").val();
    	var money = $("#money").val();
    	var date=getDate();
      //示范一个公告层
      layer.open({
        type: 1
        ,title: '<i style="color: red;">确认转账信息</i>' //不显示标题栏
        ,closeBtn: false
        ,area: '360px;'
        ,shade: 0.8
        ,id: 'LAY_layuipro' //设定一个id，防止重复弹出
        ,btn: ['继续转账', '关闭']
        ,btnAlign: 'c'
        ,moveType: 1 //拖拽模式，0或者1
        ,content: '<div style="padding: 50px; line-height: 22px; font-weight: 300;">转账目标会员：'+rid+'<br>转账金额：'+money+'<br>转账时间：'+date+'<br>二级密码：<input type="password" maxlength="6" id="paycode" placeholder="请输入支付密码"><br><hr>我们此后的征途是星辰大海 ^_^</div>'
        ,success: function(layero){
          var btn = layero.find('.layui-layer-btn');
          btn.find('.layui-layer-btn0').click(function(){
        	   var paycode=$("#paycode").val();
        	  $.post("verificationPassword.do",{"paycode":paycode==""?0:paycode,"money":money,"rid":rid},function(data){
        		  if (data) {
					alert("转账成功");
					var urlCG=window.location.href;
					window.location.href=urlCG;
				} else {
					alert("密码错误，请重新操作！");
				}
        	  })
          });
        }
      });
    }
  };
  
  $('#layerDemo .layui-btn').on('click', function(){
    var othis = $(this), method = othis.data('method');
    active[method] ? active[method].call(this, othis) : '';
  });
  
});

 
</script>
<script type="text/javascript">

/* 失去焦点检查目标会员是否可以转账 */
 function validationMemberByUsername(value){
	$.post("validationMemberByUsername.do",{"username":value},function(data){
		if (data==1) {
			$("#rid-i").html("√").css("color","green");
		} else {
			$("#rid-i").html("×").css("color","red");
		}
	})
}

 /* 失去焦点检查登录用户余额是否足够转账 */
function validationMoney(value){
	$.post("validationMoney.do",{"money":value},function(data){
		if (data) {
			$("#money-i").html("√").css("color","green");
		} else {
			$("#money-i").html("余额不足").css("color","red");
		}
	})
}
 
</script>
</head>

<body class="layui-layout-body">

	<div id="main-div-HB">
	
		当前余额： <span style="color: red;">${money}</span>（元） 
		<br /> 
		转账目标会员： <input type="text" id="rid" placeholder="输入对方的账号" onblur="validationMemberByUsername(value)"><i id="rid-i"></i><span style="color:#DE9875;">（接收转帐的会员用户名必须填写正确，不能给註册会员转帐。）</span>
		<br />
		转账金额：<input type="text" id="money" placeholder="金额必须大于0" onkeyup="value=value.replace(/[^\d]/g,'') " onblur="validationMoney(value)"><i id="money-i"></i>
		<br />
		
		<div class="site-demo-button" id="layerDemo" style="margin-bottom: 0;">
		  <button data-method="notice" class="layui-btn layui-btn-radius">提交</button>
		</div>
	</div>
	
	
	
</body>
</html>